from asyncio import sleep

from common.base_page import BasePage
from appium.webdriver.common.appiumby import AppiumBy

'''点击聊股-点击消息框-点击输入框-写入标题-点击发布按钮'''


class PostFailed(BasePage):
    '''点击聊股'''
    btn_desktop_talk = (AppiumBy.ID, 'com.jhss.youguu:id/btn_desktop_talk')
    '''点击铅笔按钮'''
    iv_public_twitter = (AppiumBy.ID, 'com.jhss.youguu:id/iv_public_twitter')
    ''''点击优顾大家谈'''    '''53,898'''
    bar_name = (AppiumBy.ID, 'com.jhss.youguu:id/bar_name')
    '''输入标题'''
    title_content = (AppiumBy.ID, 'com.jhss.youguu:id/title_content')
    # title_content = (AppiumBy.ID, 'com.jhss.youguu:id/title_content')
    '''点击发布按钮'''
    title_right_button = (AppiumBy.ID, 'com.jhss.youguu:id/title_right_button')
    '''断言'''
    Toast = (AppiumBy.XPATH, '/hierarchy/android.widget.Toast')

    def post_failed(self, connect):
        '''点击聊股'''
        self.click_ele(self.btn_desktop_talk)
        sleep(2)
        '''点击铅笔按钮'''
        self.click_ele(self.iv_public_twitter)
        '''点击优顾大家谈'''
        self.tap(53, 898)
        # self.click_ele(self.bar_name)
        sleep(2)
        '''输入标题'''
        self.send_keys(self.title_content, connect)
        sleep(4)
        '''点击发布按钮'''
        self.click_ele(self.title_right_button)
        sleep(2)
